/* ungetc example */
#include <stdio.h>

int main()
{
  FILE *pFile;
  int c;
  char buffer[256];

  pFile = fopen("myfile.txt", "rt");
  if (pFile == NULL) 
    perror("Error opening file");
  else {
    while (!feof(pFile)) {
      c = getc(pFile);
      if (c == '#')
        ungetc('@', pFile);
      else
        ungetc(c, pFile);
      fgets(buffer, 255, pFile);
      fputs(buffer, stdout);
    }
  }

  return 0;  
}